<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全局方法 Number() 将变量转换为数字</title>
</head>

<body>
    <h1>JavaScript 全局方法</h1>
    <p>Number() 方法把变量转换为数字：</p>
    <p id="demo"></p>
    <script>
        document.getElementById("demo").innerHTML =
            Number(true) + "<br>" +
            Number(false) + "<br>" +
            Number("10") + "<br>" +
            Number(" 10") + "<br>" +
            Number("10 ") + "<br>" +
            Number(" 10  ") + "<br>" +
            Number("10.33") + "<br>" +
            Number("10,33") + "<br>" +
            Number("10 33") + "<br>" +
            Number("John;")
    </script>
</body>

</html>